package processor

import (
	"fmt"
	"net"
	"study/14_practice_chat/common"
)

type ServerProcessor struct {
	Conn net.Conn
}

func (this *ServerProcessor) Processor(request common.RequestBody) (err error) {
	dataType := request.DataType
	fmt.Println("dataType = ", dataType)
	switch dataType {
	case common.Type_LogInMessage:
		fmt.Println("common.Type_LogInMessage")
		// 处理登陆消息
		var serverUserProcessor ServerUserProcessor = ServerUserProcessor{
			Conn: this.Conn,
		}
		err = serverUserProcessor.Login(request)
		if err != nil {
			fmt.Println("login failure!", err)
			return
		} else {
			fmt.Println("login successed!")
			return
		}
	default:
		fmt.Println("unknow message type!")

	}
	return
}
